<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <script src="../react/react.development.js"></script>
  <script src="../react/react-dom.development.js"></script>
  <script src="../react/babel.min.js"></script>

  <script type="text/babel">
    class App extends React.Component {
      constructor(props) {
        super(props)
        this.state = {
          movies: ['大话西游', '海王', '流浪地球', '盗梦空间']
        }
        this.btnClick = this.btnClick.bind(this)
      }
      btnClick(event) {
        console.log('按钮发生了点击', event);
      }
      liClick(item, index, event) {
        console.log('li发生了点击', item, index, event);
      }
      render() {
        return (
          <div>
            <button onClick={this.btnClick}>按钮</button>
            <ul>
              {
                this.state.movies.map((item, index, arr) => {
                  return (
                    <li className="item" onClick={(e) => this.liClick(item, index, e)} title="li">
                      {item}
                    </li>
                  )
                })
              }
            </ul>
          </div>
        )
      }
    }
    ReactDOM.render(<App />, document.getElementById('app'))
  </script>
</body>

</html>